import { Entity, PrimaryColumn, Column, CreateDateColumn, OneToMany, OneToOne, JoinColumn, } from 'typeorm';
import { WristbandAdv } from './wristband_adv.entity';
import { StudentWristband } from './student_wristband.entity';
@Entity('wristband')
export class Wristband {
  @Column({ type: 'varchar', length: 255 })
  id: string;

  @PrimaryColumn({ type: 'char', length: 17 })
  mac: string; // MAC 地址作为主键

  @Column({ type: 'char', length: 10, default: '' })
  fw_name: string; // 固件名称

  @Column({ type: 'smallint', default: 0 })
  fw_version: number; // 固件版本

  @CreateDateColumn({ type: 'timestamp', nullable: true })
  time: Date; // 操作时间

  @Column({ type: 'boolean', default: false })
  deleted: boolean;

  // Define the one-to-many relationship to WristbandAdv
  @OneToMany(() => WristbandAdv, (wristbandAdv) => wristbandAdv.wristband)
  wristbandAdv: WristbandAdv[];


  @OneToOne(() => StudentWristband)
  @JoinColumn({ name: 'mac', referencedColumnName: 'mac' })
  student_wristband: StudentWristband;

}